package test6;
public class TestThrows {
    public static void computer() throws ArithmeticException{
    int x=(int) (1+(Math.random() *2));
    int y=(int) (Math.random() *2);
    int result;
    result=x/y;
    System.out.println("the result is:"+result);
}
    public static void exp(ArithmeticException e){
        System.out.println("ArithmeticException类的对象出现");
        e.printStackTrace();
    }
    public static void main(String[] args){
        try {
            computer();
        }catch (ArithmeticException e){
            exp(e);
        }finally {
            System.out.println("finally块执行：代码已执行完毕");
        }
    }
}
